package com.woniu.controller;

import com.woniu.util.MinIOUtil;
import com.woniu.util.ResponseEnum;
import com.woniu.util.ResponseUtil;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;

import javax.annotation.Resource;
import java.util.Map;

@RestController
@RequestMapping("/upload")
public class UploadController {
    @Resource
    private MinIOUtil minIOUtil;
    @PostMapping
    public ResponseUtil upload(MultipartFile file) throws Exception {
        Map<String, Object> map = minIOUtil.upload(file, "test");
        if (map.get("code").equals(200)){
            return ResponseUtil.get(ResponseEnum.OK,map);
        }else {
            return ResponseUtil.get(ResponseEnum.FAIL);
        }
    }

}
